import 'package:flutter/material.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

class MsgSearchPage extends StatefulWidget {
  const MsgSearchPage({super.key});

  @override
  State<MsgSearchPage> createState() => _MsgSearchPageState();
}

class _MsgSearchPageState extends State<MsgSearchPage>
    with SingleTickerProviderStateMixin {
  @override
  void initState() {
    super.initState();
  }

  // 数据源，假设每条数据包含一个标题和内容
  var dataSource = List.generate(
    10,
    (index) => {'title': '标题 $index', 'content': '这是内容 $index'},
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: TDTheme.of(context).grayColor1,
      body: Stack(
        children: [
          Positioned(
            top: 0,
            left: 0,
            right: 0,
            child: Image.asset(
              'assets/images/home/home_topbg.png',
              fit: BoxFit.cover,
              height: 200,
            ),
          ),
          Column(
            children: [
              Container(
                width: double.infinity,
                padding: EdgeInsets.only(top: 30, bottom: 20),
                child: Row(
                  children: [
                    const Expanded(child: SizedBox()),
                    TDText('搜索',
                        textAlign: TextAlign.left,
                        font: TDTheme.of(context).fontTitleMedium),
                    const Expanded(child: SizedBox()),
                  ],
                ),
              ),
              Container(
                width: double.infinity,
                padding: EdgeInsets.only(left: 20, right: 20),
                child: TDInput(
                  leftIcon: const Icon(TDIcons.app),
                  // controller: controller[11],
                  backgroundColor: Colors.white,
                  hintText: '请输入文字',
                  onChanged: (text) {
                    setState(() {});
                  },
                  onClearTap: () {
                    // controller[11].clear();
                    // setState(() {});
                  },
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
  }
}
